<template>
  <Dialog v-model="dialogVisible" title="评价模板详情" width="800px">
    <el-descriptions :column="2" border>
      <el-descriptions-item label="模板名称">
        {{ templateData.templateName || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="模板类型">
        <el-tag>{{ getTypeName(templateData.templateType) }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="适用职业">
        {{ templateData.professionName || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="技能等级">
        <el-tag>{{ getLevelName(templateData.skillLevel) }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="总分">
        {{ templateData.totalScore || 0 }}分
      </el-descriptions-item>
      <el-descriptions-item label="及格分">
        {{ templateData.passScore || 0 }}分
      </el-descriptions-item>
      <el-descriptions-item label="状态">
        <el-tag :type="templateData.status === 1 ? 'success' : 'danger'">
          {{ templateData.status === 1 ? '启用' : '禁用' }}
        </el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="是否默认">
        <el-tag :type="templateData.isDefault === 1 ? 'success' : 'info'">
          {{ templateData.isDefault === 1 ? '是' : '否' }}
        </el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="模板说明" :span="2">
        <div style="white-space: pre-wrap; max-height: 200px; overflow-y: auto;">
          {{ templateData.templateDesc || '-' }}
        </div>
      </el-descriptions-item>
      <el-descriptions-item label="创建时间">
        {{ templateData.createTime || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="更新时间">
        {{ templateData.updateTime || '-' }}
      </el-descriptions-item>
    </el-descriptions>
    
    <!-- 模板配置详情 -->
    <el-divider content-position="left">模板配置</el-divider>
    <el-table :data="templateData.configList || []" border style="width: 100%">
      <el-table-column prop="itemName" label="评价项目" />
      <el-table-column prop="itemScore" label="分值" width="80" />
      <el-table-column prop="itemWeight" label="权重" width="80">
        <template #default="{ row }">{{ row.itemWeight }}%</template>
      </el-table-column>
      <el-table-column prop="itemDesc" label="说明" />
    </el-table>
    
    <template #footer>
      <el-button @click="dialogVisible = false">关闭</el-button>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const dialogVisible = ref(false)
const templateData = ref({} as any)

const getTypeName = (type: number) => {
  const typeMap = { 1: '理论考试', 2: '实操考试', 3: '综合评价' }
  return typeMap[type] || '-'
}

const getLevelName = (level: number) => {
  const levelMap = { 1: '初级', 2: '中级', 3: '高级', 4: '技师', 5: '高级技师' }
  return levelMap[level] || '-'
}

const open = (data: any) => {
  dialogVisible.value = true
  templateData.value = data
}

defineExpose({ open })
</script> 